
/* -----------------
* brief 
* 1. this is code gen by tools
*/

package service

import (
	"github.com/mjiulee/lego"
)
import . "saas_sys_base/modules/config/models"

type ConfigService struct {
	// add your model here
	tbConfig Config
}


func (t* ConfigService)ListConfig(keyword string,page,psize int) ([]map[string]string, int64, error) {
	// 业务查询
	queryMap := map[string]interface{}{
		"table":  map[string]string{"table": "tb_config", "alias": "t1"},
		"fields": []string{"t1.*"},
		"join": []map[string]string{
			// map[string]string{"table": "tb_xx as t2", "on": "t2.xid = t1.id"},
		},
		"where": []lego.QMapWhereField{
			//{"t1.if_del", "=", 0, "AND", false},
		},
		"search": map[string]string{
			//"t1.id": req.Keyword,
		},
		"orders": []string{"t1.id asc"},
		"page": map[string]int{
			"page":  page,
			"psize": psize,
		},
	}
	return lego.QueryListByMap(queryMap)
}

/* 根据id获取记录
 * -----------------
 */
func (t* ConfigService) GetConfigById(id int64) *Config {
	return t.tbConfig.RecodeById(id)
}

/* 添加
 * -----------------
 */
func (t* ConfigService) SaveConfig(item2add *Config) bool {
	return t.tbConfig.AddRecode(item2add)
}

/* 删除(硬删除)*/
func (t* ConfigService) DelConfigById(id int64) bool {
	return t.tbConfig.DelRecodeById(id)
}

/* 更新
 * -----------------*/
func (t* ConfigService) UpdateConfig(rc *Config) bool {
	return t.tbConfig.UpdateRecode(rc)
}

/*

*/
/*
func (t* ConfigService) GetConfigByWho(who common.Who) (*common.AppConfig, error) {
	config := t.tbConfig.RecodeByWho(who)
	if config == nil {
		return nil, errors.New("config not found")
	}

	// to do 如果权限小于配置文件权限级别，则不能使用配置

    return config, nil
}*/

//自定义函数

